var casper = require('casper').create({
    verbose: true,
    logLevel: "debug",
    clientScripts: ["jquery.js"]
});

casper.start('http://www.baidu.com/', function() {
    this.echo(this.getTitle());
});

casper.then(function() {
    this.fill('form[action="/s"]', { wd: '城里套路深,我要回农村' }, false);
});

casper.then(function() {
    this.page.onConsoleMessage = function(e) {
        console.log(e);
    };
    var result=this.evaluate(function () {
        $("form ").submit();
        return 'go submit';
    });
    console.log(result);
});
casper.then(function () {
    this.capture('search-results.png');
});

function getTitles() {
    console.log('123');
    $("form ").submit();
    return $("form ").html();
}

casper.run();